package com.genius.adminmanager.user.controller;

import javax.servlet.http.HttpSession;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONObject;
import com.genius.adminmanager.menu.entity.MenuJson;
import com.genius.adminmanager.other.entity.ResponseJson;
import com.genius.adminmanager.user.service.UserService;
import com.genius.workflow.log.ControllerLog;

@Controller
public class SelectController {
	@Autowired
    @Qualifier("userSelectService")
    private UserService userSelectService;
    /**
     * 跳转到列表页面
     * @param session
     * @return
     * @throws Exception
     */
	@RequiresPermissions("0aa6ddf1b6484f01979de471488973e1")
    @GetMapping("/adminmanager/user/toSelect")
    public String toIndex(){
        return "/views/adminmanager/user/select";
    }
    @GetMapping("/adminmanager/user/photo_select")
    public String photo_select(){
        return "/views/adminmanager/user/photo_select";
    }
    @GetMapping("/adminmanager/user/password_select")
    public String password_select(){
        return "/views/adminmanager/user/password_select";
    }
    @ControllerLog(description="获取用户列表字段权限")
    @GetMapping("/adminmanager/user/getSelectHead")
    @ResponseBody
    public JSONObject getSelectHead(HttpSession session){
        JSONObject response = new JSONObject();
        response.put(ResponseJson.code, 0);
        JSONObject json = new JSONObject();
        json.put(MenuJson.menuId, "0aa6ddf1b6484f01979de471488973e1");
        response = userSelectService.getSelectHead(json, session, response);
        return response;
    }
    /**
     * 查询数据
     * @return
     * @throws Exception
     */
    @ControllerLog(description="查看用户列表数据")
    @PostMapping("/adminmanager/user/getSelectBody")
    @ResponseBody
    public JSONObject getSelectBody(@RequestBody JSONObject json){
        JSONObject response = new JSONObject();
        response.put(ResponseJson.code, 0);
        response = userSelectService.getSelectBody(json, response);
        return response;
    }

	/**
     * 跳转到页面
     */
    @GetMapping("/mobile_page/adminmanager/toUsersTree")
    public String toUsersTree(){
        return "/views/unite_platform/mobile_page/adminmanager/usersTree";
    }
    /**
     * 跳转到页面
     */
    @GetMapping("/mobile_page/adminmanager/tomobileUsersTree")
    public String tomobileUsersTree(){
        return "/views/unite_platform/mobile_page/adminmanager/mobile_userTree";
    }
    /**
     * 查询数据
     * @return
     * @throws Exception
     */
    @ControllerLog(description="查看头像")
    @PostMapping("/adminmanager/user/getphoto")
    @ResponseBody
    public JSONObject getphoto(@RequestBody JSONObject json){
        JSONObject response = new JSONObject();
        response.put(ResponseJson.code, 0);
        response = userSelectService.getphoto(json, response);
        return response;
    }
    /**
     * 查询数据
     * @return
     * @throws Exception
     */
    @ControllerLog(description="查看密码")
    @PostMapping("/adminmanager/user/getpassword")
    @ResponseBody
    public JSONObject getpassword(@RequestBody JSONObject json){
        JSONObject response = new JSONObject();
        response.put(ResponseJson.code, 0);
        response = userSelectService.getpassword(json, response);
        return response;
    }
}
